package com.traffic.managent.model.phone;

import java.util.List;

import com.traffic.managent.annotation.ModelBind;
import com.traffic.managent.base.SessionUser;
import com.traffic.managent.jedis.RedisKit;
import com.traffic.managent.plugin.ParamInitThread;

@ModelBind(table = "cx_phone_head", key = "phoneSeg")
public class PhoneHead extends SessionUser<PhoneHead> {

	private static final long serialVersionUID = 1L;
	public static final PhoneHead dao = new PhoneHead();

	/**
	 * 根据province 获取所有地市
	 * 
	 * @param province
	 *            省编号
	 * @return
	 */
	public List<PhoneHead> getAllArea(String province) {
		return dao.find(
				"select areaCode, cityName from cx_phone_head where province =" + province + " group by areaCode ");
	}
	
	public List<PhoneHead> findProvinceArea() {
		return dao.find(
				"SELECT phoneSeg,CONCAT(operator,'|',province,'|',provinceName,'|',operatorName,'|',areaCode,'|',cityName) AS cvalues FROM cx_phone_head");
	}
	
	/**
	 * 添加或者更新缓存
	 */
	public void cacheAdd(String ids, String value) {
		RedisKit.put(ParamInitThread.cacheStart_phone_heads + ids, value);
	}
}
